package decorator_pattern;

/**
 * @author lynn
 * @date 18-12-8 上午7:23
 */
public class StringDecorator implements Component{

    private String content;

    public StringDecorator(String content) {
        this.content = content;
    }

    /**
     * get all columns
     *
     * @return
     */
    @Override
    public int getColumns() {
        return content.getBytes().length;
    }

    /**
     * get all rows
     *
     * @return
     */
    @Override
    public int getRows() {
        return 1;
    }

    /**
     * get text for given row number
     *
     * @param row
     * @return
     */
    @Override
    public String getRowText(int row) {

        if(0 == row){
            return content;
        }else{
            return null;
        }

    }
}
